package com.aidex.biz.utils;

import com.aidex.common.utils.http.HttpUtils;
import com.alibaba.fastjson.JSONObject;

public class AddressUtil {

    public static  final String txmapkey = "7NRBZ-6VI3O-CXBW5-S7KC2-DB4LF-Y4FFS";
    //https://apis.map.qq.com/ws/geocoder/v1/?address=

    public static JSONObject geocoder(String address){
        String url="https://apis.map.qq.com/ws/geocoder/v1/?address="+address.replace(" ","")+"&key=" + txmapkey;
        String result = HttpUtils.doGet(url);
        return JSONObject.parseObject(result).getJSONObject("result").getJSONObject("address_components");
    }

    public static void main(String[] args) {
        System.out.println(geocoder("湖北省宜昌市伍家岗区东山大道温馨岛小区211-303".replace(" ","")));
    }
}
